package yf.mall.enums;

import com.yf.response.RRException;
import lombok.Data;
import yf.mall.enums.app.AppCourseHotEnum;

import java.util.Arrays;

public enum LevelEnum {

    YK(5L, "游客", 5),
    DZ(4L, "店主", 4),
    DR(3L, "达人", 3),
    FW(2L, "招生专员", 2),
    LY(1L, "服务机构", 1);

    public String name;

    public Integer lv;

    public Long levelId;

    public static String[] names(){
        return Arrays.stream(LevelEnum.values()).map(m->m.levelId).toArray(String[]::new);
    }

    LevelEnum(Long levelId, String name, Integer lv) {
        this.levelId = levelId;
        this.name = name;
        this.lv = lv;
    }

    public static LevelEnum levelOf(Long levelId){
       for (LevelEnum levelEnum : LevelEnum.values()){
           if(levelEnum.levelId.equals(levelId)){
               return levelEnum;
           }
       }
       return null;
    }

    public static Integer getLv(Long levelId){
        for (LevelEnum levelEnum:LevelEnum.values()){
            if(levelEnum.levelId.equals(levelId)){
                return levelEnum.lv;
            }
        }
        throw new RRException("级别有误");
    }

}
